package priv.pront.code.lanqiao.competition.course.date0330;

import java.util.*;

public class 和为T {
    static List<Integer> list = new ArrayList<>();
    static Set<int[]> set = new HashSet<>();
    static int n;
    static long T;
    static int[] arr;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        T = scanner.nextInt();
        backtracking(0, 0);
        for (int[] ints : set) {
            for (int anInt : ints) {
                System.out.print(anInt + " ");
            }
            System.out.println();
        }
        System.out.println(set.size());
    }

    //   没有剪枝操作的回溯
    private static void backtracking(int startIndex, int sum) {
        if (startIndex != 0 && sum == T) {
            add(list);
        }
        for (int i = startIndex; i < arr.length; i++) {
            sum += arr[i];
            list.add(arr[i]);
            backtracking(i + 1, sum);
            sum -= arr[i];
            list.remove(list.size() - 1);
        }
    }

    private static void add(List<Integer> list) {
        int[] arr = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            arr[i] = list.get(i);
        }
        set.add(arr);
    }
}
